﻿using Microsoft.AspNetCore.Mvc;
using Nop.Core;
using Nop.Core.Domain.Orders;
using Nop.Services.Localization;
using Nop.Web.Framework.Components;
using System.Linq;

namespace Nop.Plugin.Payments.HPay.Components
{
    [ViewComponent(Name = "HPayViewComponent")]
    public class PaymentInfoViewComponent : NopViewComponent
    {

        private readonly ILocalizationService _localizationService;
        private readonly IStoreContext _storeContext;
        private readonly IWorkContext _workContext;

        public PaymentInfoViewComponent(
         ILocalizationService localizationService,
         IStoreContext storeContext,
         IWorkContext workContext)
        {

            this._localizationService = localizationService;
            this._storeContext = storeContext;
            this._workContext = workContext;
        }


        public IViewComponentResult Invoke()
        {
            PaymentInfoModel model = new PaymentInfoModel()
            {
                CartIds = string.Join(',', _workContext.CurrentCustomer.ShoppingCartItems.Where(s => s.ShoppingCartType == ShoppingCartType.ShoppingCart).Select(s => s.Id).ToList())
            };
            return View("~/Plugins/Payments.HPay/Views/PaymentInfo.cshtml", model);
        }
    }
}
